qcollect-traits 0.6.0

Traits for being generic over collection-types.
//! TODO impl Reserve
//!

use traits::*;

use vec_map::{self, VecMap};

use std::collections::Bound;

impl<T> OrderedCollection for VecMap<T> {}

impl<T> Len for VecMap<T> {
    fn len(&self) -> usize { (*self).len() }
} 

impl<T> Capacity for VecMap<T> {
    fn capacity(&self) -> usize { (*self).capacity() }
}

impl<T> Clear for VecMap<T> {
    fn clear(&mut self){ (*self).clear() }
}

// TODO
/*impl<T> Reserve for VecMap<T> {
    fn reserve(&mut self, n: usize){ 
        (*self).reserve(n) 
    }
    fn reserve_exact(&mut self, n: usize){ (*self).reserve_exact(n); }
}*/

impl<'i, T> Contains<&'i usize> for VecMap<T> {
    fn contains(&self, key: &'i usize) -> bool { (*self).contains_key(key) }
}

impl<'a, 'i, T: 'a> _Get<'a, &'i usize> for VecMap<T> {
    type Ret = Option<&'a T>;
}

impl<'i, T: 'static> Get<&'i usize> for VecMap<T> {
    fn get<'a>(&'a self, key: &'i usize) -> <Self as _Get<'a, &'i usize>>::Ret { (*self).get(key) }
}

impl<'a, 'i, T: 'a> _GetMut<'a, &'i usize> for VecMap<T> {
    type Ret = Option<&'a mut T>;
}

impl<'i, T: 'static> GetMut<&'i usize> for VecMap<T> {
    fn get_mut<'a>(&'a mut self, key: &'i usize) -> <Self as _GetMut<'a, &'i usize>>::Ret { (*self).get_mut(key) } 
}

impl<'a, T: 'a> _Iterate<'a> for VecMap<T> {
    type Iter = vec_map::Iter<'a, T>;
}

impl<T: 'static> Iterate for VecMap<T> {
    fn iter<'a>(&'a self) -> <Self as _Iterate<'a>>::Iter { (*self).iter() }
}

impl<'a, T: 'a> _IterateMut<'a> for VecMap<T> {
    type IterMut = vec_map::IterMut<'a, T>;
}

impl<T: 'static> IterateMut for VecMap<T> {
    fn iter_mut<'a>(&'a mut self) -> <Self as _IterateMut<'a>>::IterMut { (*self).iter_mut() }
}

impl<T> Insert<(usize, T)> for VecMap<T> {
    type Ret = Option<T>;
    fn insert(&mut self, pair: (usize, T)) -> Self::Ret { (*self).insert(pair.0, pair.1) }
}

impl<T> Insert2<usize, T> for VecMap<T> {
    type Ret = Option<T>;
    fn insert(&mut self, key: usize, val: T) -> Self::Ret { (*self).insert(key, val) }
}

impl<'i, T> Remove<&'i usize> for VecMap<T> {
    type Ret = Option<T>;
    fn remove(&mut self, key: &'i usize) -> Self::Ret { (*self).remove(key) }
}